@<template>
  <div>
     <!-- 面包屑导航区 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图区域 -->
    <el-card>
      <el-row>
        <el-col :span="8">
          <el-input placeholder="请输入内容">
          <el-button slot="append" class="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>

    <!-- form展示区域 -->
   <el-table :data="orderList" style="width: 100%" border stripe>
      <el-table-column type="index"></el-table-column>
      <el-table-column  prop="order_number" label="订单列表" width="200"></el-table-column>
      <el-table-column  prop="order_price" label="订单价格" ></el-table-column>
      <el-table-column  prop="pay_status" label="是否付款" >
        <template slot-scope="scope">
          <el-tag v-if="scope.row.pay_status == 0" type="warning" >未付款</el-tag>
          <el-tag  v-else type="success" >已付款</el-tag>
        </template>
      </el-table-column>
      <el-table-column  prop="is_send" label="是否发货" ></el-table-column>
      <el-table-column  label="下单时间" >
        <template slot-scope="scope" >
          {{scope.row.update_time| dataFormat}}
        </template>
      </el-table-column>
      <el-table-column  label="操作" >
        <template>
          <el-button type="primary" size="mini" class="el-icon-edit" @click="editLoaction">编辑</el-button>
          <el-button @click="showPressTime" type="success" size="mini" class="el-icon-location">地址</el-button>
        </template>
      </el-table-column>
      
    </el-table>

    <!-- 分页区域 -->
        <el-pagination background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="orderInfo.pagenum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="orderInfo.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
    </el-card>

    <!-- 省市县对话框 -->
    <el-dialog
    title="修改地址"
    :visible.sync="dialogVisible"
    width="50%"
    >
    <!-- 表单区域 -->
    <el-form ref="formRef" :model="orderInfo" label-width="80px" :rules="orderRules">
      <el-form-item label="省市区/县:" prop="cityList" label-width="100px">
        <el-cascader
        v-model="orderInfo.cityList"
        :options="citydata"
        :props="{ expandTrigger: 'hover' }"
        @change="handleChange"></el-cascader>
      </el-form-item>
       <el-form-item label="详细地址:" prop="detilLocation"  label-width="100px">
        <el-input placeholder="请输入详细地址"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
    </span>
  </el-dialog>


  </div>

</template>

<script>
import citydata from './citydata'
export default {
  data() {
    return {
      // 订单列表查询对象
      orderInfo: {
        query: '',
        pagenum: 1,
        pagesize: 10,
        cityList: []

      },
      // 订单列表存储对象
      orderList: [],
      // 共多少条订单
      total: 0,
      // 城市数据
      citydata,
      // 对话框显示或隐藏
      dialogVisible: false,
      // 测试物流单号
      pressId: '804909574412544580',
      // 验证规则
      orderRules: {
        cityList:[
          {required: true, message: '请选择', trigger: 'blur'}
        ],
        detilLocation: [
          {required: true, message: '请输入详细地址', trigger: 'blur'}
        ]
      }
    
    }
  },
  created() {
    this.getOrderList()
  },
  methods: {
    async getOrderList() {
      const {data: res} = await this.$http.get('orders', {params: this.orderInfo})
      if(res.meta.status != 200) {
        return this.$message.error('订单列表获取失败')
      }
      console.log(res.data)
      this.orderList = res.data.goods
      this.total = res.data.total
    },
    // 页面条数变化处理事件
    handleSizeChange(newSize){
      this.orderInfo.pagesize = newSize
    },
    // 页面引用变化的处理函数
    handleCurrentChange(newNum){
      this.orderInfo.pagenum = newNum
    },
    editLoaction() {
      this.dialogVisible = true
    },
    // 级联选择发生改变
    handleChange() {
      console.log(this.orderInfo.cityList)
    },
    // 展示时间线
    showPressTime() {
      // this.$http.get(`/kuaidi/${this.pressId}`).then(res => {
      // console.log(res)
      // })
      console.log('获取时间线,接口有问题')
      
    }
  },
 

}
</script>

<style lang="less" scoped>
.el-cascader {
  width: 100%;
  margin-left: 0;
}
</style>>
